<%@ page language="java" pageEncoding="UTF-8"
	errorPage="../../defaultException.jsp"%>
<%@include file="../../tags.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>特色项推荐信息</title>
<%@include file="../../head.jsp"%>
</head>
<body>
		<table id="list_data_title" style="width: 400px">

			<thead>
				<tr>
					<th data-options="field:'link',formatter:formatCell">是否发布</th>
					<th data-options="field:'featureItemId',width:100">特色项Id</th>
					<th data-options="field:'zhname',width:100">特色项标题</th>
					<th field="source" formatter="renderItemImg">特色项图片</th>
				</tr>
			</thead>
		</table>

<script type="text/javascript">
function formatCell(value,row,index){
	   if (value == 1){
		   return "<input name='link' checked='checked' type='checkbox'/>";
	   }
	   else{
		   return "<input name='link' type='checkbox'/>";
	   }
}
function renderItemImg(value, row, index) {
	return "<img src='${image_domain}"+value+"' width='150' height='100'>";
}
$('#list_data_title').datagrid({ 
    title:'特色项推荐信息', 
    iconCls:'icon-add',//图标 
    width: 1024, 
    height: 'auto', 
    nowrap: false, 
    striped: true, 
    border: true, 
    collapsible:false,//是否可折叠的 
    fit:true,
    remoteSort:false,  
    onLoadSuccess:function(data){
    	$(":checkbox[name='link']").each(function(index){
    		$(this).attr('index',index);
			$(this).click(function(){
				var index = $(this).attr('index');
				var rows = $('#list_data_title').datagrid('getData').rows;
				var check = $(this).attr('checked');
				var row = rows[index];
				if(check=='checked'){
					row['checkInfo'] = 'add';
				}

				var saveAction = "${cpath}/admin/dest/feature/select/item/save";
				$.post(saveAction, row, function(result) {
					if (result.resultCode === '00000000') {
						$('#list_data_title').datagrid('reload'); // reload the user data
						$.messager.alert("提示", result.resultMsg, "info");
					} else {
						$.messager.alert("错误", result.resultMsg, "error");
						$('#list_data_title').datagrid('reload');
					}
				}, 'json');
			});
		});
    },
    url:'${cpath}/admin/dest/feature/select/item/all?featureId=${featureId}',
    singleSelect:false,//是否单选 
    rownumbers:true,
    pagination:true,//分页控件
    idField:'featureItemId'
}); 
//设置分页控件 
var p = $('#list_data_title').datagrid('getPager'); 
$(p).pagination({ 
    pageSize: 10,//每页显示的记录条数，默认为10 
    pageList: [5,10,15],//可以设置每页记录条数的列表 
    beforePageText: '第',//页数文本框前显示的汉字 
    afterPageText: '页    共 {pages} 页', 
    displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',
    onBeforeRefresh:function(){
        $(this).pagination('loading');
        //alert('before refresh');
        $(this).pagination('loaded');
    }
});  
</script>
	<style type="text/css">
#fm {
	margin: 0;
	padding: 20px 20px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 5px;
}

.fitem label {
	display: inline-block;
	width: 90px;
}

td {
	white-space: nowrap;
}
</style>
</body>
</html>